from zope.component import provideUtility, provideAdapter
from pydataportability.microformats.base.interfaces import IHTMLParser, IHTMLNode

# html5
try:
    from html5libparser import HTML5LibParser, HTML5LibNode
    provideUtility(HTML5LibParser, IHTMLParser, name="html5lib")
    provideAdapter(HTML5LibNode)
    print "Ok"
except ImportError:
    print "nOK"
    pass
from html5libparser import HTML5LibParser, HTML5LibNode
    
# beautifulsoup
try:
    from beautifulsoup import BeautifulSoupHTMLParser, BeautifulSoupHTMLNode
    provideUtility(BeautifulSoupHTMLParser, IHTMLParser, name="beautifulsoup")
    provideAdapter(BeautifulSoupHTMLNode)
except ImportError:
    pass
    
# etree
try:
    from etree import ElementTreeHTMLParser, ElementTreeHTMLNode
    provideUtility(ElementTreeHTMLParser, IHTMLParser, name="elementtree")
    provideAdapter(ElementTreeHTMLNode)
except ImportError:
    pass


